<extend name="default/template/base_index" />

<block name="area_header">
    <style type="text/css">
        td{
            text-align: center;
        }
        td pre{
            HEIGHT: 160PX;
            width:480px;
        }
        .object-code{
            width:480px;
            HEIGHT: 160PX;
            display: block;
            margin:0 auto;
            word-wrap: break-word;
            text-align: left;
            overflow: scroll;
            overflow-x: hidden;
        }
    </style>
</block>

<block name="area_body">
    {:W('Menus/topbar')}
    <div class="admin-main container-fluid">
        {:W('Menus/left')}
        <div class="admin-main-content">
            {:W('Menus/breadcrumb')}

            <div class="h4">网仓信息上报</div>
            <form class="post_form">

                <a href="javascript:history.back(-1);" class="btn btn-default btn-sm"><i class="fa fa-reply"></i>返回</a>
                <br>

                <div class="form-group">
                    <!--<label>订单编号</label>-->
                    <!--<div class=" ">{$order.order_code}</div>-->
                    <label>上报订单编号</label>
                    <div class=" ">{$order.pay_code}</div>
                </div>

                <div class="form-group "  style="padding: 10px">
                    <label>网仓状态变更纪录</label>
                    <table class="table  table-bordered table-hover">
                        <thead>
                        <tr>
                            <td style="width:200px;" >时间</td>
                            <td>说明</td>
                        </tr>
                        </thead>

                        <volist name="history" id="vo">
                            <tr>

                                <td style="width:200px;" >{$vo.create_time|date='Y-m-d H:i:s',###}</td>

                                <td>{$vo.reason}</td>

                            </tr>
                        </volist>

                    </table>

                </div>

                <div class="text-center">
                    <empty name="cant_cancel">
                    <a target-form="post_form" href="{:U('Admin/NetWH/index',array('order_code'=>I('get.order_code')))}" data-loading-text="正在上报中..."  class="ajax-post btn btn-sm btn-primary">3.2 推送订单到网仓</a>
                    <a target-form="post_form" href="{:U('Admin/NetWH/cancel',array('order_code'=>I('get.order_code')))}" data-loading-text="正在上报中..."  class="ajax-post btn btn-sm btn-primary">3.10 取消订单</a>
                    </empty>
                    <in name="order['zjport_status']" value="34,51,52,53">
                        <empty name="shipped">
                        <a target-form="post_form" href="{:U('Admin/NetWH/package',array('order_code'=>I('get.order_code')))}" data-loading-text="正在上报中..."  class="ajax-post btn btn-sm btn-primary">3.3 请求网仓发货</a>
<else/>
                            <a href="#" disabled="disabled" class="disabled btn btn-sm btn-primary">网仓已发货,等候运单出区</a>
                        </empty>
                            <else/>
                    <a href="#" disabled="disabled" data-loading-text="正在上报中..."  class="disabled btn btn-sm btn-primary">3.3 请求网仓发货</a>
                    </in>
                </div>
                <div class="text-center text-danger">
                    [3.3 请求网仓发货] 操作，必须等待电子口岸回执接收之后，才能进行操作
                </div>
                <div class="js_info text-center">

                </div>
            </form>



            <div class="" style="padding: 10px">
                <h5>
                    <label>海关运单出区回执</label></h5>
                    <table class="table table-bordered">
                    <thead>
                        <tr>
                            <td  style="width:200px">出区时间</td>
                            <td>运单号</td>
                            <td>出区状态</td>
                            <td>核放单号</td>
                        </tr>
                    </thead>

                    <volist name="bill_list" id="vo">
                        <tr>
                            <td  style="width:200px">{:date("Y-m-d H:i:s",$vo['out_time'])}</td>
                            <td ><span  title="">{$vo.express_no}</span></td>
                            <td >
                                <eq name="vo['out_state']"  value="1">
                                    已出区
                                </eq>
                                {$vo.out_state}
                            </td>
                            <td>

                            </td>
                        </tr>
                    </volist>
                </table>
            </div>


            <div class="" style="padding: 10px">
                <h5>
                    <label>上报历史纪录</label></h5>
                <table class="table table-bordered">
                    <thead>
                    <tr>
                        <td  style="width:200px">上报时间</td>
                        <td>返回结果</td>
                        <td>上报参数</td>
                    </tr>
                    </thead>
                    <volist name="list" id="vo">
                        <tr>
                            <td  style="width:200px">{:date("Y-m-d H:i:s",$vo['upload_time'])}</td>
                            <td ><span  title="">{:getNetWHResult($vo['result'])}</span></td>
                            <td ><span class="object-code" title="{$vo.upload_content}">{$vo.upload_content}</span></td>

                        </tr>
                    </volist>
                </table>
                <div>{$show}</div>
            </div>

        </div>

        <!-- END admin-main-content -->
    </div>
    <!-- END admin-main-->
</block>

<block name="area_footer">

    <script>
    function upload(){
        var order_code = "{$order.order_code}";

        $.ajax({
            url:"__SELF__",
            data:{order_code:order_code},
            type:"POST",
            beforeSend:function(){
                $(".J_upload").button("loading");
            }
        }).always(function(){
            $(".J_upload").button("reset");
        }).done(function(data){
            console.log(data);
            if(data.status){
                $(".js_info").html(data.info);
                window.location.reload();
            }else{
                $(".js_info").html(data.info);
                $.scojs_message(data.info , $.scojs_message.TYPE_ERROR);
            }
        }).fail(function(){
            $.scojs_message("上报失败!请刷新后重试!", $.scojs_message.TYPE_ERROR);
        });

    }

    $(function(){

        $(".J_upload").click(function(){

            upload();

        });

    })



    </script>

</block>